<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>逾期催收列表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">任务人</div>
                    <div class="field">
                        <input name="usrNm" id="usrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">合同编号</div>
                    <div class="field">
                        <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">事业部</div>
                    <div class="field">
                        <input name="buOrgCd" id="buOrgCd" placeholder="请选择" ltype="combobox">
                    </div>
                </div>

                <div class="fieldBox">
                    <div class="label">逾期天数</div>
                    <div class="field">
                        <input ligerui="width: 82" name="ovdDaysMin" id="ovdDaysMin" type="text" class="ui-textbox"
                               value="" validate="{number:true}">
                        -
                        <input ligerui="width: 82" name="ovdDaysMax" id="ovdDaysMax" type="text" class="ui-textbox"
                               value="" validate="{number:true}">
                    </div>
                </div>

                <div class="fieldBox">
                    <div class="label">应收日期</div>
                    <div class="field">
                        <input ligerui="width: 82" name="ovdDtMin" id="ovdDtMin" type="text" class="ui-datepicker"
                               value="">
                        -
                        <input ligerui="width: 82" name="ovdDtMax" id="ovdDtMax" type="text" class="ui-datepicker"
                               value="">
                    </div>
                </div>
                 <div class="fieldBox" id="searchPrjTypCdId">
              <div class="label">项目类型</div>
                <div class="field">
                <select name="prjTypCd"  id="prjTypCd" >
                 <option value="" selected="selected">请选择</option>
                 <c:forEach items="${projectTypeList}" var="opt">
                  <option value="${opt.key}">${opt.value}</option>
                 </c:forEach>
                </select>
                </div>
            </div>
              <div class="fieldBox col_33" id="searchInsCodeId">
                <div class="label">第三方机构</div>
                          <div class="field">
                            <select name="insCode"  id="insCode" >
                             <option value="" selected="selected">请选择</option>
                           <c:forEach items="${friBaseList}" var="fri">
                            <option value="${fri.insCode}">${fri.fundRasInsNm}</option>
                           </c:forEach>
                          </select>
                          </div>
                </div>
                
                <div class="fieldBox">
                   <div class="label">客户经理</div>
                   <div class="field">
                       <input name="cstMgrName" id="cstMgrName" type="text" class="ui-textbox" value="">
                   </div>
               </div>

                <%--<div class="fieldBox" id="searchCstMgrRgnCdId">
                    <div class="label">所属区域</div>
                    <div class="field">
                        <select name="cstMgrRgnCd"  id="cstMgrRgnCd" >
                            <option value="" selected="selected">请选择</option>
                            <c:forEach items="${regionList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>--%>

                <div class="fieldBox" id="tableSearchBox">
                    <div class="label">贷款业务类型</div>
                    <div class="field">
                        <select name="tableNm" id="tableNm">
                            <option value="">请选择</option>
                            <option value="MCR_BILL_M">小贷业务</option>
                            <option value="PBL_BILL_M">垫款业务</option>
                            <option value="OTHERS">租赁业务</option>
                        </select>
                    </div>
                </div>


                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="appoBtn" class="sq-button sq-button-round">预约</span>
                    <sys:funcAuth resCd="MovdExportBtn">
                        <span id="exportXlsxBtn" class="sq-button sq-button-round">导出</span>
                    </sys:funcAuth>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                    <span id="outbound" class="sq-button sq-button-round">外呼</span>
                </div>
                <div class="clearFix"></div>
            </div>
        </form>
    </div>
    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_head">
            <table class="table_full">
                <tr>
                    <td><b>应收总金额合计(元): </b><span id="arAmt"/></td>
                    <td><b>逾期金额合计(元): </b><span id="ovdAmt"/></td>
                    <td><b>罚息金额合计(元): </b><span id="fineAmt"/></td>
                </tr>
            </table>
        </div>
        <div class="sqPanel_body">
            <div id="ligergrid1" class="sq-grid"></div>
        </div>
    </div>
</div>

<!-- 预约 -->
<div id="appo_div" style="display:none">
    <form id="appo_formSet">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">预约时间<span class="requiredSymbol">*</span></div>
                <div class="field">
                    <input name="appoDt" id="appoDt" type="text" class="ui-datepicker"
                           validate="{required:true}">
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span id="confirmBtn" class="sq-button sq-button-round l-dialog-btn-ok">确定</span>
            <span id="cancelBtn" class="sq-button sq-button-round co_normal l-dialog-btn-cancel">取消</span>
        </div>
    </form>
</div>

<script type="text/javascript">
    var grid = null, form = null,contractGrid = null,paySchGrid=null;
    $(function () {
        var url = '<%=path%>/risk/overdueCollect/initMyTask.do';
        grid = $("#ligergrid1").ligerGrid({
            url:url,
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', minWidth: 200, align: 'left', enabledSort: false, render: function (rowdata, rowindex, value, column) {
                        if(StringUtils.isEmpty(value)){
                            value = "";
                        }
                        var h = '';
                        h='<a href="javascript:showDetail(';
                        h+="'"+rowdata.cstId+"'";
                        h+=')">'+value+'</a>'
                        return h;
                    }},
                {display: '风险级别', name: '？？', width: 100, align: 'right', enabledSort: false},
                {display: '客户经理', name: 'cstMgrNm', width: 100, align: 'right', enabledSort: false},
                {display: '逾期合同数', name: 'ovdCntQty', width: 100, align: 'right', enabledSort: false},
                {display: '逾期支付表数', name: 'ovdPayQty', width: 100, align: 'right', enabledSort: false},
                {display: '逾期天数', name: 'ovdDays', width: 100, align: 'right', enabledSort: false},
                /*{display: '所属区域', name: 'cstMgrRgnCdNm', width: 100, align: 'right', enabledSort: false},*/
                {
                    display: '应收金额(元)', name: '', width: 100, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<a style="cursor: pointer;" onclick="overduePaySchDCST(' + rowdata.cstId + ','+rowdata.arAmt + ','+ rowdata.ovdAmt + ','+ rowdata.fineAmt+');">&yen;' + FormatMoney(rowdata.arAmt/100) + '</a> ';
                    }
                },
                {
                    display: '逾期金额(元)', name: 'ovdAmt', width: 100, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.ovdAmt / 100);
                    }
                },
                {
                    display: '罚息金额(元)', name: 'fineAmt', width: 100, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.fineAmt / 100);
                    }
                },
                {
                    display: '操作', width: 430, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="repaymentDtl(' + rowdata.cstId + ',\'' + rowdata.cstNm + '\');"><i class="sqBtnIco_49"></i>还款明细</a>  ' +
                                '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="qyCommRec(' + rowdata.cstId + ',\'' + rowdata.cstNm +  '\',' + (rowdata.ovdAmt+rowdata.fineAmt)+ ',' + rowdata.minOverdueDate+ ');"><i class="sqBtnIco_51"></i>催收记录</a>' +
                                '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="overdueDtl(' + rowdata.cstId + ');"><i class="sqBtnIco_50"></i>逾期汇总</a> ' +
                                '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="calculator(' + rowdata.cstId+','+ rowdata.arAmt + ',' + rowdata.ovdAmt + ','+rowdata.fineAmt+','+ rowdata.ovdDays +');"><i class="sqBtnIco_51"></i>应收款计算</a>' ;
                            /*'<a class="sq-button-hasicon" style="cursor: pointer;" onclick="toCCardDataView(' + rowdata.cstId +',&quot;'+ rowdata.cstNm+'&quot;)"><i class="sqBtnIco_51"></i>C卡数据</a>';*/
                    }
                },
            ],
            pageSize: 50,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            allowUnSelectRow: true,
            alternatingRow: false,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            },
            detail: {
                height: 'auto',
                onShowDetail: showContractGrid
            },
            frozen: false,
            checkbox:true
        });
        grid.setHeight(100);
        //预约
        $("#appoBtn").click(function (event) {
            var selectedRows = detailGrid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }

            $.ligerDialog.SQopen({
                width: 400,
                title: '预约',
                target: $("#appo_div")
            });
            $("#appo_formSet").ligerForm({
                validate: true
            });
        });
        $("#confirmBtn").click(function (event) {
            var ligerForm = liger.get("appo_formSet");
            if (!ligerForm.valid()) {
                $.ligerDialog.SQalert({content: "请选择预约时间！", SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var selectedRows = detailGrid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push({'cstId': selectedRows[index].cstId, 'paySchId': selectedRows[index].paySchId});
            }
            data['ids'] = JSON.stringify(_ids);
            data['buTypCd'] = 1;//逾期催收
            $.ligerDialog.hide();

            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: '<%=path%>/risk/rskAppoRec/add.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        //frameElement.dialog.close();
                        $.ligerDialog.hide();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        $("#cancelBtn").click(function (event) {
            $.ligerDialog.hide();
        });
        // 外呼
        $("#outbound").click(function (event){
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            var data = {};
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].cstId);
            }
            data['ids'] = JSON.stringify(_ids);
            $.ligerDialog.hide();
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: '<%=path%>/risk/rskCommRec/outboundList.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {

                        //$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        alert("外呼成功");
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        //frameElement.dialog.close();
                        $.ligerDialog.hide();
                        grid.reload();

                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        //事业部
        $("#buOrgCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        form = $("#searchBar").ligerForm();
        liger.get("buOrgCd").setData(${buOrgCdList});

        getOvdAmtSummary();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
            getOvdAmtSummary();
            //detailGrid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        var exportUrl = '<%=path%>/risk/overdueCollect/exportMyTaskExcel.do'

      //导出
        $("#exportXlsxBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                url: exportUrl,
                data:data,
                beforeSend:function(){
                    wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        window.open(msg.data);
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        }); 
        
        //导出PDF
        $("#exportPdfBtn").click(function (event) {
            exportOverDue("pdf");
        });
        //导出Excel
        /*$("#exportXlsBtn").click(function (event) {
            exportOverDue("xls");
        });*/
    });
    /**
     * 到C卡页面
     */
    function toCCardDataView(cstId,cstNm){
        parent.parent.mainApp.f_addTab('ccard'+cstId,cstNm+'的C卡数据','<%=path%>/riskctrl/ccardv2/toCcardV2CstInfoPage.do?cstId='+cstId+ '&cstNm='+cstNm);
    }
    /**
     * 应收款计算
     **/
    function calculator(cstId,arAmt,ovdAmt,fineAmt,ovdDay){
        $.ligerDialog.open({
            width: 450,
            height: 280,
            title: '应付金额计算',
            url: '<%=path%>/risk/overdueCollect/toCalculator.do?arAmt='+arAmt + '&ovdAmt='+ovdAmt + '&fineAmt='+ fineAmt + '&ovdDay=' +ovdDay+"&cstId="+cstId,
        });
    }
    // 客户详情页面
    function showDetail(_id){
        parent.parent.mainApp.f_addTab('tab_customer_np_detail'+_id,'客户详情','<%=path%>/customer/cstbscinfo/showDetail.do?id='+_id);
        <%--parent.pageInTab.addTabItem({tabid:'tab_customer_np_detail'+_id,text:'客户详情',url:'<%=path%>/customer/cstbscinfo/showDetail.do?id='+_id});--%>
    }

    //查询汇总
    function getOvdAmtSummary() {
        var data = form.getData();
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: '<%=path%>/risk/overdueCollect/myTaskSum.do',
            success: function (msg) {
                $("#arAmt").text(FormatMoney(msg.arAmt / 100));
                $("#ovdAmt").text(FormatMoney(msg.ovdAmt / 100));
                $("#fineAmt").text(FormatMoney(msg.fineAmt / 100));
            }
        });
    }

    /* 还款明细 */
    function repaymentDtl(cstId, cstNm) {
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        $.ligerDialog.SQopen({
            width: 850,
            height: 500,
            title: '还款明细',
            url: '<%=path%>/risk/overdueCollect/toCstCapFundListPage.do?cstId=' + cstId + "&cstNm=" + cstNm,
            buttons: [
                {
                    text: "关闭", onclick: onCancel, type: 'cancel'
                }
            ]
        });
    }

    /* 逾期明细 */
    function overdueDtl(cstId) {
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        $.ligerDialog.SQopen({
            width: 850,
            height: 500,
            title: '逾期明细',
            url: '<%=path%>/capital/capOverdueInfo/toOverdueDtl.do?cstId=' + cstId,
            buttons: [
                {
                    text: "关闭", onclick: onCancel, type: 'cancel'
                }
            ]
        });
    }
    function getSearchParam(){
        form = liger.get("searchBar");
        var data = form.getData();
        return data;
    }

    /**
     * 显示客户下的逾期合同
     */
    function showContractGrid(row,detailPanel,callback){

        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        var searchParam = getSearchParam();
        var url = '<%=path%>/risk/overdueCollect/overdueContractList.do?cstId=' + row.cstId + '&myTask=1&cstMgrNm='+row.cstMgrNm
        contractGrid = $(gridBox).ligerGrid({
            url: url,
            method: 'get',
            columns: [
                {
                    display: '事业部', name: 'buOrgCd', width: 120
                },
                {display: '合同号', name: 'lsCntNo', width: 160 ,render:function(rowdata){
                    if(rowdata.tableName == "PRJ_PRD_PAY_SCH_M" || rowdata.tableName == "MCR_BILL_M" ){
                        return '<a style="cursor: pointer;" onclick="contractLink(' + rowdata.prjId +',\''+ rowdata.tableName + '\');">' + rowdata.lsCntNo+ '</a> ';
                    }else{
                        return rowdata.lsCntNo ;
                    }
                }},
                { display: '逾期期次', name: 'minPayPd', width: 150, enabledSort:true},
                { display: '逾期日期', name: 'minOverdueDate', minWidth: 100 , enabledSort:true,render:renderDate},
                {display: '逾期天数', name: 'ovdDays', width: 120, },
                {display: '诉讼状态', name: 'sueStsCd', width: 120 },
                {display: '应收金额', name: 'arAmt', width: 120, align: 'left',
                    render: function (rowdata, index, value) {
                        // if(rowdata.tableName=="PRJ_PRD_PAY_SCH_M"){
                            return '<a style="cursor: pointer;" onclick="overduePaySchDPRJ(' + rowdata.prjId +','+ rowdata.arAmt + ','+ rowdata.ovdAmt + ',' + rowdata.fineAmt+  ');">&yen;' + FormatMoney(rowdata.arAmt/100) + '</a> ';
                        // }else{
                        //     return '&yen;'+ FormatMoney(rowdata.arAmt/100);
                        // }
                    }},
                {
                    display: '逾期金额', name: 'ovdAmt', width: 120, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.ovdAmt / 100);
                    }
                },
                {
                    display: '罚息金额', name: 'findAmt', width: 120, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.fineAmt / 100);
                    }
                }
            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers: true,  //显示序号
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false,
            detail: {
                height: 'auto',
                onShowDetail: showPaySchGrid
            }
        });
    }

    function contractLink(prjId,tableName){
        if(tableName){
            if(tableName=='PRJ_PRD_PAY_SCH_M'){//融资租赁
                Add_navTab('tab_project_detail'+prjId,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag=true&&id='+prjId+'&&detailFlag=true');
            }else if(tableName=="MCR_BILL_M"){ //小贷
                Add_navTab('MCR_BILL_M_'+prjId,'小贷账单详情',"<%=path%>/mcr/mcrBillM/toBillDtlPage.do?id="+prjId);
            }
        }
    }
    /**
     * 显示某个合同下面的支付表 grid
     * @param row
     * @param detailPanel
     * @param callback
     */
    function showPaySchGrid(row,detailPanel,callback){
        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        var searchParam = getSearchParam();
        var url = '<%=path%>/risk/overdueCollect/overduePaySchList.do?prjId=' + row.prjId + '&myTask=1'
        contractGrid = $(gridBox).ligerGrid({
            url: url,
            method: 'get',
            columns: [
                {
                    display: '支付表号', name: 'paySchNo', width: 200,render:function(rowdata){
                        var tableName = rowdata.tableName;
                        if(tableName=="PRJ_PRD_PAY_SCH_M"){
                            return '<a style="cursor: pointer;" onclick="paySchLink(' + rowdata.paySchId +',\''+ rowdata.tableName + '\','+ rowdata.prjId+ ',' + rowdata.prjPrdDtlId+');">' + rowdata.paySchNo+ '</a> ';
                        }else{
                            return rowdata.paySchNo;
                        }
                    }
                },
                {display: '支付表状态', name: 'prdStsCd', width: 160 },
                { display: '逾期期次', name: 'payPd', width: 150, enabledSort:true},
                { display: '逾期日期', name: 'overdueDate', minWidth: 100 , enabledSort:true,render:renderDate},
                {display: '逾期天数', name: 'overdueDay', width: 120, },
                {display: '应收金额', name: 'arAmt', width: 120, align: 'left',
                    render: function (rowdata, index, value) {
                        return '<a style="cursor: pointer;" onclick="overduePaySchDPAY(' + rowdata.paySchId + ','+rowdata.arAmt+','+rowdata.ovdAmt+','+rowdata.fineAmt+');">&yen;' + FormatMoney(rowdata.arAmt/100) + '</a> ';
                    }},
                {
                    display: '逾期金额', name: 'ovdAmt', width: 120, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.ovdAmt / 100);
                    }
                },
                {
                    display: '罚息金额', name: 'fineAmt', width: 120, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.fineAmt / 100);
                    }
                },
                {
                	display: '结清价', name: 'prdStsCd', width: 160 ,
                	render:function(rowdata,index,value){
                        return '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="clearingPriceDetail(' + rowdata.paySchId + ','+rowdata.arAmt+','+rowdata.ovdAmt+','+rowdata.fineAmt+',\''+rowdata.tableName+'\','+rowdata.overdueDay+');">查看结清价</a>  ' ;
            		}
                },
                {
                	display: '操作', name: 'caozuo', width: 160 ,
                	render:function(rowdata,index,value){
                        var tableName = rowdata.tableName;
                        if(tableName=="PRJ_PRD_PAY_SCH_M"){
                            return '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="carDetail(' + rowdata.paySchId + ');"><i class="sqBtnIco_49"></i>车辆详情</a>  ' ;
                        }else{
                            return "";
                        }
                	}
            	}

            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers: true,  //显示序号
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false,
        });
    }
    function paySchLink(paySchId,tableName,prjId,prjPrdDtlId){
        if(tableName){
            // WTF
            if(tableName == "PRJ_PRD_PAY_SCH_M"){ //融资租赁

                Add_navTab('tab_prj_quat_prps'+paySchId,'查看支付表','<%=path%>/project/prjprdpayschm/toDetailPage.do?id='+paySchId);
            }
        }
    }
    function carDetail(paySchId){
        parent.parent.mainApp.f_addTab('tab_oberdue_cardetail','车辆详情','<%=path%>/risk/overdueCollect/carDetail.do?paySchId='+paySchId);
    }

    //导出PDF、导出Excel
    function exportOverDue(format) {
        var form = liger.get("searchBar");
        var data = form.getData();
        var req = "format=" + format;
        for (name in data) {
            for (name in data) {
                if (data[name]) {
                    req = req + "&" + name + "=" + data[name];
                }
            }
        }
        window.location.href = "<%=path%>/capital/capOverdueInfo/exportOverdue.do?" + req;
    }

    //查询催收记录
  //查询催收记录
    function qyCommRec(_cstId, _cstNm,_ovdAmt, _minOverdueDate) {
        parent.parent.mainApp.f_addTab('rsk_cmm_rec'+_cstId,'催收记录','<%=path%>/risknew/rskCommRecNew/toListPage.do?cstId='+_cstId+'&&cstNm='+ _cstNm +'&&ovdAmt='+ _ovdAmt+'&&minOverdueDate='+ _minOverdueDate);
    }


     

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    //查看支付表明细
    function showPaySchDetail(paySchId){
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/risk/ovdCollect/getPayInfo.do?paySchId='+paySchId,
            success: function (msg) {
                if (msg.success == 1) {
                    Add_navTab('tab_prj_quat_prps'+paySchId,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+msg.data.prjId+'&&id='+paySchId+'&&prjPrdDtlId='+msg.data.prjPrdDtlId+'&&prjPrdId='+msg.data.prjPrdId+'&&detailFlag=true');
                }
            }
        });
    }

    /**
     * 点击用户应收金额
     */
    function overduePaySchDCST(cstid,arAmt,ovdAmt,fineAmt){
        overduePaySchD(cstid,'','',arAmt,ovdAmt,fineAmt);
    }

    /**
     * 点击项目应收金额
     * @param prjId
     */
    function overduePaySchDPRJ(prjId,arAmt,ovdAmt,fineAmt){
        overduePaySchD('',prjId,'',arAmt,ovdAmt,fineAmt);

    }

    /**
     * 点击支付表应收金额
     */
    function overduePaySchDPAY(paySchId,arAmt,ovdAmt,fineAmt){
        overduePaySchD('','',paySchId,arAmt,ovdAmt,fineAmt)
    }

    function overduePaySchD(cstId,prjId,paySchId,arAmt,ovdAmt,fineAmt){
        parent.parent.mainApp.f_addTab('tab_overdue_payschd','应收金额','<%=path%>/risk/overdueCollect/toOverduePaySchDList.do?cstId='+cstId + '&prjId='+prjId + '&paySchId=' + paySchId + '&arAmt='+arAmt + '&ovdAmt='+ovdAmt + '&fineAmt='+fineAmt);
    }
    //查看结清价
    function clearingPriceDetail(paySchId,arAmt,ovdAmt,fineAmt,tableNm,overdueDay){
        parent.parent.mainApp.f_addTab('tab_overdue_clearingprice','结清详情','<%=path%>/risk/overdueCollect/toOverdueClearingPrice.do?paySchId=' + paySchId+'&arAmt='+arAmt+'&ovdAmt='+ovdAmt+'&fineAmt='+fineAmt+'&tableNm='+tableNm+'&overdueDay='+overdueDay);
    }
</script>

</body>
</html>
